package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.StorageTypeStat;
import com.ruoyi.system.mapper.StorageTypeStatMapper;
import com.ruoyi.system.service.StorageTypeStatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 存储类型占比统计 Service 实现类
 *
 * @author 你的名字
 */
@Service
public class StorageTypeStatServiceImpl implements StorageTypeStatService {
    @Autowired
    private StorageTypeStatMapper storageTypeStatMapper;

    @Override
    public List<StorageTypeStat> selectStorageTypeStatList(StorageTypeStat storageTypeStat) {
        return storageTypeStatMapper.selectStorageTypeStatList(storageTypeStat);
    }

    @Override
    public StorageTypeStat selectStorageTypeStatById(Long id) {
        return storageTypeStatMapper.selectStorageTypeStatById(id);
    }

    @Override
    public int insertStorageTypeStat(StorageTypeStat storageTypeStat) {
        return storageTypeStatMapper.insertStorageTypeStat(storageTypeStat);
    }

    @Override
    public int updateStorageTypeStat(StorageTypeStat storageTypeStat) {
        return storageTypeStatMapper.updateStorageTypeStat(storageTypeStat);
    }

    @Override
    public int deleteStorageTypeStatById(Long id) {
        return storageTypeStatMapper.deleteStorageTypeStatById(id);
    }

    @Override
    public int deleteStorageTypeStatByIds(Long[] ids) {
        return storageTypeStatMapper.deleteStorageTypeStatByIds(ids);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int batchSaveStorageTypeStat(List<StorageTypeStat> list) {
        // 1. 删除所有旧数据
        storageTypeStatMapper.deleteAllStorageTypeStat();
        // 2. 批量插入新数据
        return storageTypeStatMapper.batchInsertStorageTypeStat(list);
    }
}